class Solution:
    def wiggleSort(self, nums):
        n = len(nums)
        nums_sorted = sorted(nums)
        mid = (n + 1) // 2
        small = nums_sorted[:mid]
        large = nums_sorted[mid:]
        
        # 交叉合并，注意要从后往前取以避免重复元素的影响
        for i in range(n):
            if i % 2 == 0:
                nums[i] = small.pop()
            else:
                nums[i] = large.pop()
